<?php

namespace backend\models;

use Yii;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "{{%jjr_user_commission}}".
 *
 * @property string $id
 * @property int $jjr_user_id 经纪人ID
 * @property int $jjr_user_project_id 项目ID
 * @property string $amount 佣金
 * @property string $create_time 创建时间
 * @property string $update_time 更新时间
 * @property int $status 状态
 * @property int $transfer_status 结佣状态，1 未结佣，2结佣中,3已结佣 4,结佣失败
 */
class JjrUserCommission extends \common\core\BaseActiveRecord
{
    const TRANSFER_NOT_START="1";
    const TRANSFER_STARTED="2";
    const TRANSFER_END="3";
    const TRANSFER_FAIL="4";
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%jjr_user_commission}}';
    }
    public function behaviors()
    {
        return [
            [
                'class' => TimestampBehavior::className(),
                'attributes' => [
                    # 创建之前
                    \yii\db\ActiveRecord::EVENT_BEFORE_INSERT => ['create_time', 'update_time'],
                    # 修改之前
                    \yii\db\ActiveRecord::EVENT_BEFORE_UPDATE => ['update_time']
                ],
                #设置默认值
                'value' =>date('Y-m-d H:i:s')
            ]
        ];
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['jjr_user_id', 'jjr_user_project_id', 'amount', 'transfer_status'], 'required'],
            [['jjr_user_id', 'jjr_user_project_id', 'status', 'transfer_status'], 'integer'],
            [['amount'], 'number'],
            [['create_time', 'update_time'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'jjr_user_id' => '经纪人ID',
            'jjr_user_project_id' => '项目ID',
            'amount' => '佣金',
            'create_time' => '创建时间',
            'update_time' => '更新时间',
            'status' => '状态',
            'transfer_status' => '结佣状态', //，1 未结佣，2已结佣，3结佣中
        ];
    }
}